pokemon <- read.csv('~/Documents/University/semester5/Data Science/practice/data/pokemon_fix-1.csv')
## install.packages("dplyr")
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
## install.packages('ggplot2')
library(ggplot2)
## practice1
glimpse(pokemon)
## Rows: 801
## Columns: 40
## $ abilities <chr> "['Overgrow', 'Chlorophyll']", "['Overgrow', 'Chloro…
## $ against_bug <dbl> 1.00, 1.00, 1.00, 0.50, 0.50, 0.25, 1.00, 1.00, 1.00…
## $ against_dark <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
## $ against_dragon <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
## $ against_electric <dbl> 0.5, 0.5, 0.5, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0, 1.0, 1.…
## $ against_fairy <dbl> 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 1.0, 1.0, 1.0, 1.0, 1.…
## $ against_fight <dbl> 0.50, 0.50, 0.50, 1.00, 1.00, 0.50, 1.00, 1.00, 1.00…
## $ against_fire <dbl> 2.0, 2.0, 2.0, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 2.0, 2.…
## $ against_flying <dbl> 2.0, 2.0, 2.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.…
## $ against_ghost <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0…
## $ against_grass <dbl> 0.25, 0.25, 0.25, 0.50, 0.50, 0.25, 2.00, 2.00, 2.00…
## $ against_ground <dbl> 1.0, 1.0, 1.0, 2.0, 2.0, 0.0, 1.0, 1.0, 1.0, 0.5, 0.…
## $ against_ice <dbl> 2.0, 2.0, 2.0, 0.5, 0.5, 1.0, 0.5, 0.5, 0.5, 1.0, 1.…
## $ against_normal <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
## $ against_poison <dbl> 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.…
## $ against_psychic <dbl> 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1…
## $ against_rock <dbl> 1, 1, 1, 2, 2, 4, 1, 1, 1, 2, 2, 4, 2, 2, 2, 2, 2, 2…
## $ against_steel <dbl> 1.0, 1.0, 1.0, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 1.0, 1.…
## $ against_water <dbl> 0.5, 0.5, 0.5, 2.0, 2.0, 2.0, 0.5, 0.5, 0.5, 1.0, 1.…
## $ attack <int> 49, 62, 100, 52, 64, 104, 48, 63, 103, 30, 20, 45, 3…
## $ base_egg_steps <int> 5120, 5120, 5120, 5120, 5120, 5120, 5120, 5120, 5120…
## $ base_happiness <int> 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, …
## $ base_total <int> 318, 405, 625, 309, 405, 634, 314, 405, 630, 195, 20…
## $ capture_rate <chr> "45", "45", "45", "45", "45", "45", "45", "45", "45"…
## $ classfication <chr> "Seed Pokemon", "Seed Pokemon", "Seed Pokemon", "Liz…
## $ defense <int> 49, 63, 123, 43, 58, 78, 65, 80, 120, 35, 55, 50, 30…
## $ experience_growth <int> 1059860, 1059860, 1059860, 1059860, 1059860, 1059860…
## $ height_m <dbl> 0.7, 1.0, 2.0, 0.6, 1.1, 1.7, 0.5, 1.0, 1.6, 0.3, 0.…
## $ hp <int> 45, 60, 80, 39, 58, 78, 44, 59, 79, 45, 50, 60, 40, …
## $ name <chr> "Bulbasaur", "Ivysaur", "Venusaur", "Charmander", "C…
## $ percentage_male <dbl> 88.1, 88.1, 88.1, 88.1, 88.1, 88.1, 88.1, 88.1, 88.1…
## $ pokedex_number <int> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1…
## $ sp_attack <int> 65, 80, 122, 60, 80, 159, 50, 65, 135, 20, 25, 90, 2…
## $ sp_defense <int> 65, 80, 120, 50, 65, 115, 64, 80, 115, 20, 25, 80, 2…
## $ speed <int> 45, 60, 80, 65, 80, 100, 43, 58, 78, 45, 30, 70, 50,…
## $ type1 <chr> "grass", "grass", "grass", "fire", "fire", "fire", "…
## $ type2 <chr> "poison", "poison", "poison", "", "", "flying", "", …
## $ weight_kg <dbl> 6.9, 13.0, 100.0, 8.5, 19.0, 90.5, 9.0, 22.5, 85.5, …
## $ generation <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
## $ is_legendary <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0…
R 패키지 중 dplyr를 설치하여 glimpse 함수를 사용할 수 있도록 설정한다.
glimpse는 str와 비슷하지만 row와 column 수를 확인 할수 있도록 하는 함수로 리스트에 대한 설명을 볼 수 있도록 한다.
pokemon$type1 <- factor(pokemon$type1)
##levels(pokemon$type1)
##table(pokemon$type1)
type1.total <- aggregate(cbind(attack, defense, speed, hp, sp_attack, sp_defense) ~ type1, data=pokemon, FUN= mean)
barplot(cbind(type1.total$attack, type1.total$defense, type1.total$speed, type1.total$hp, type1.total$sp_attack, type1.total$sp_defense) ~ type1.total$type1,
beside=T, col=rainbow(6), xlab="type", ylab = "average", main="graph of type1",horiz=F, cex.main=1,cex.lab=1)
#axis(side=2, at=seq(0,120,20))
legend("topright", legend=c("attack", "defense", "speed", "HP", "sp_attack", "sp_defense"), fill=rainbow(6))
| 특징 | 높은 type |
|---|---|
| attack | Dragon, fighting, gound |
| defense | Steel, rock, fighting |
| speed | Flying, electric |
| HP | Dragon (큰차이 없음) |
| sp_attack | Psychic, dragon, fire 등( 큰차이 없음) |
| sp_defense | Psychic, dragon, fairy 등 (큰 차이 없음) |
type1.total
## type1 attack defense speed hp sp_attack sp_defense
## 1 bug 70.12500 70.84722 63.56944 56.72222 56.65278 62.51389
## 2 dark 87.79310 70.51724 75.31034 72.55172 74.51724 69.06897
## 3 dragon 106.40741 86.25926 76.11111 79.85185 89.59259 84.55556
## 4 electric 70.82051 61.82051 85.41026 60.51282 87.53846 70.05128
## 5 fairy 62.11111 68.16667 53.66667 73.94444 81.50000 87.77778
## 6 fighting 99.17857 66.39286 64.28571 71.42857 50.10714 63.42857
## 7 fire 81.50000 67.78846 73.34615 68.73077 87.73077 71.53846
## 8 flying 66.66667 65.00000 99.66667 68.00000 84.00000 70.00000
## 9 ghost 72.74074 79.51852 58.33333 63.37037 82.44444 78.29630
## 10 grass 73.76923 70.87179 59.02564 65.35897 74.32051 69.23077
## 11 ground 94.81250 83.90625 59.96875 73.18750 51.93750 62.28125
## 12 ice 73.30435 71.91304 62.73913 72.08696 77.43478 76.13043
## 13 normal 75.16190 59.69524 69.53333 76.72381 56.98095 63.20000
## 14 poison 72.65625 70.03125 64.18750 65.59375 61.56250 65.53125
## 15 psychic 65.56604 69.26415 75.15094 72.94340 92.60377 85.73585
## 16 rock 90.66667 96.26667 57.42222 66.33333 63.20000 73.37778
## 17 steel 93.08333 120.20833 56.58333 66.79167 72.70833 82.20833
## 18 water 73.30702 73.48246 63.92105 70.21930 74.06140 71.79825
type 별로 공력, 방어력, 스피트, HP, 특수공격, 특수 방어의 차이는 위와 같은 수치로 볼 수 있다.
| 특징 | 높은 type |
|---|---|
| attack | Dragon(106) |
| defense | Steel(120) |
| speed | Flying(99) |
| HP | Dragon (79), Normal(76) |
| sp_attack | Psychic (92), Dragon(89), Electric(87) |
| sp_defense | Fairy(87), Psychic(85), dragon(84) |
plot(pokemon$weight_kg,pokemon$height_m)
plot(pokemon$weight_kg,pokemon$defense)
plot(pokemon$weight_kg,pokemon$speed)
plot(pokemon$height_m,pokemon$defense)
plot(pokemon$height_m,pokemon$speed)
size_byheight<-quantile(pokemon$height_m,na.rm=T)
size_divide<-cut(pokemon$height_m,breaks=size_byheight,include.lowest = T)
levels(size_divide)<-c('Very small ~0.6m','Small 1m','Big 1.5m','Very Big 14m')
table(size_divide)
## size_divide
## Very small ~0.6m Small 1m Big 1.5m Very Big 14m
## 264 169 185 163
plot(size_divide,pokemon$defense)
plot(size_divide,pokemon$speed)
plot결과로 보면 키 크기에 따라 defense가 높아지는 경향이 있다. speed의 경우 키 크기에 따라 작은 포켓몬(1m이하)보다는 큰 몬스터가 더 빠르다. 그러나 1.5m와 14m 정도의 포켓몬 스피트 차이를 크게 보이지 않는다. 덩치를 height와 weight 둘중 하나만 사용해도 괜찮을 것으로 보인다. (둘다 비슷한 plot 값을 보이기 때문에 그렇게 하고, 이중 height를 2개 그룹으로만 나누는 방법이 아직 확실하지 않아서 quantile 로 4가지로 나눴다.)
모든 포켓몬 801마리 중 height값이 NA인 포켓몬을 제외한 781마리의 포켓몬을 미터 기준으로 나눠진다.
도현 ’s Solution
##1
size_byheight<-quantile(pokemon$height_m,na.rm=T)
size_divide<-cut(pokemon$height_m,breaks=size_byheight,include.lowest = T)
levels(size_divide)<-c('Very small ~0.6m','Small 1m','Big 1.5m','Very Big 14m')
table(size_divide)
## size_divide
## Very small ~0.6m Small 1m Big 1.5m Very Big 14m
## 264 169 185 163
plot(size_divide,pokemon$speed)
##2
size_byweight<-quantile(pokemon$weight_kg,na.rm=T)
size_divide2<-cut(pokemon$weight_kg,breaks=size_byweight,include.lowest = T)
levels(size_divide2)<-c('Very light 9kg','light 27.3kg','heavy 64.8kg','Very heavy 999kg')
table(size_divide2)
## size_divide2
## Very light 9kg light 27.3kg heavy 64.8kg Very heavy 999kg
## 199 192 195 195
‘덩치가 크다’의 기준을 ‘키가 크다’와 ‘몸무게가 많이 나간다’로 정의해서 진행하였다. 키가 크면 -> defense가 높은가?는 데이터 plot을 통해 유의미한 결과를 낳는다. boxplot을 보면 우상향 하는 것을 볼 수 있기에 키가 크면 defense가 높다고 할 수 있다. 키가 작으면 -> speed가 빠른가?는 데이터 plot을 통해 그렇지 않음을 알 수 있다. boxplot을 보면 하위 25%의 very small 구간이 오히려 가장 느린 speed 평균치를 보여주고 있음을 볼 수 있고, 상위 75%의 Big 구간이 가장 빠른 speed를 가짐을 알 수 있다.
몸무게가 많이 나가면 -> defense가 높은가?는 데이터 plot을 통해 유의미한 결과를 낳는다. boxplot을 보면 우상향 하는 것을 볼 수 있기에 몸무게가 많이 나가면 defense가 높다고 할 수 있다. 몸무게가 적게 나가면 -> speed가 빠른가?는 데이터 plot을 통해 그렇지 않음을 알 수 있다. boxplot을 보면 하위 25%의 very light 구간이 오히려 가장 느린 speed 평균치를 보여주고 있음을 볼 수 있고, 상위 75%의 heavy 구간이 가장 빠른 speed 평균치를 가짐을 알 수 있다.
종합적으로 보면 덩치가 큰 포켓몬은 defense가 높음을 알 수 있고, 덩치가 작은 포켓몬은 speed가 빠르지 않음을 알 수 있다.
plot(size_divide2, pokemon$defense)
plot(size_divide,pokemon$speed)
# generation.? <- aggregate(? ~ generation, data = pokemon, FUN = mean)의 형태는 세대 별로
# ?의 평균 수치를 나타낸 것이다.
generation.attack <- aggregate(attack ~ generation, data = pokemon, FUN = mean)
generation.defense <-aggregate(defense ~ generation, data = pokemon, FUN = mean)
generation.speed <-aggregate(speed ~ generation, data = pokemon, FUN = mean)
generation.hp <-aggregate(hp ~ generation, data = pokemon, FUN = mean)
generation.sp_attack <-aggregate(sp_attack ~ generation, data = pokemon, FUN = mean)
generation.sp_defense <-aggregate(sp_defense ~ generation, data = pokemon, FUN = mean)
generation.is_legendary <-aggregate(is_legendary ~ generation, data = pokemon, FUN = mean)
generation.base_total <-aggregate(base_total ~ generation, data = pokemon, FUN = mean)
generation.experience_growth <-aggregate(experience_growth ~ generation, data = pokemon, FUN = mean)
generation.base_happiness <-aggregate(base_happiness ~ generation, data = pokemon, FUN = mean)
generation.base_egg_steps <-aggregate(base_egg_steps ~ generation, data = pokemon, FUN = mean)
generation.against_bug <-aggregate(against_bug ~ generation, data = pokemon, FUN = mean)
generation.against_dark <-aggregate(against_dark ~ generation, data = pokemon, FUN = mean)
generation.against_dragon <-aggregate(against_dragon ~ generation, data = pokemon, FUN = mean)
generation.against_electric <-aggregate(against_electric ~ generation, data = pokemon, FUN = mean)
generation.against_fairy <-aggregate(against_fairy ~ generation, data = pokemon, FUN = mean)
generation.against_fight <-aggregate(against_fight ~ generation, data = pokemon, FUN = mean)
generation.against_fire <-aggregate(against_fire ~ generation, data = pokemon, FUN = mean)
generation.against_flying <-aggregate(against_flying ~ generation, data = pokemon, FUN = mean)
generation.against_ghost <-aggregate(against_ghost ~ generation, data = pokemon, FUN = mean)
generation.against_grass <-aggregate(against_grass ~ generation, data = pokemon, FUN = mean)
generation.against_ground <-aggregate(against_ground ~ generation, data = pokemon, FUN = mean)
generation.against_ice <-aggregate(against_ice ~ generation, data = pokemon, FUN = mean)
generation.against_normal <-aggregate(against_normal ~ generation, data = pokemon, FUN = mean)
generation.against_poison <-aggregate(against_poison ~ generation, data = pokemon, FUN = mean)
generation.against_psychic <-aggregate(against_psychic ~ generation, data = pokemon, FUN = mean)
generation.against_rock <-aggregate(against_rock ~ generation, data = pokemon, FUN = mean)
generation.against_steel <-aggregate(against_steel ~ generation, data = pokemon, FUN = mean)
generation.against_water <-aggregate(against_water ~ generation, data = pokemon, FUN = mean)
# 각 세대 별로 ?의 평균 수치를 정리한 다음 generation.total이라는 데이터프레임에 모두 합쳐준다.
generation.total <- merge(generation.attack, generation.defense)
generation.total <- merge(generation.total, generation.speed)
generation.total <- merge(generation.total, generation.hp)
generation.total <- merge(generation.total, generation.sp_attack)
generation.total <- merge(generation.total, generation.sp_defense)
generation.total <- merge(generation.total, generation.is_legendary)
generation.total <- merge(generation.total, generation.base_total)
generation.total <- merge(generation.total, generation.experience_growth)
generation.total <- merge(generation.total, generation.base_happiness)
generation.total <- merge(generation.total, generation.base_egg_steps)
generation.total <- merge(generation.total, generation.against_bug)
generation.total <- merge(generation.total, generation.against_dark)
generation.total <- merge(generation.total, generation.against_dragon)
generation.total <- merge(generation.total, generation.against_electric)
generation.total <- merge(generation.total, generation.against_fairy)
generation.total <- merge(generation.total, generation.against_fight)
generation.total <- merge(generation.total, generation.against_fire)
generation.total <- merge(generation.total, generation.against_flying)
generation.total <- merge(generation.total, generation.against_ghost)
generation.total <- merge(generation.total, generation.against_grass)
generation.total <- merge(generation.total, generation.against_ground)
generation.total <- merge(generation.total, generation.against_ice)
generation.total <- merge(generation.total, generation.against_normal)
generation.total <- merge(generation.total, generation.against_poison)
generation.total <- merge(generation.total, generation.against_rock)
generation.total <- merge(generation.total, generation.against_steel)
generation.total <- merge(generation.total, generation.against_water)
barplot(cbind(generation.total$attack) ~ generation.total$generation, beside=T, col=rainbow(7), xlab="generation", ylab = "attack average", main="graph of attack")
barplot(cbind(generation.total$defense) ~ generation.total$generation, beside=T, col=rainbow(7), xlab="generation", ylab = " defense average", main="graph of defense")
barplot(cbind(generation.total$speed) ~ generation.total$generation, beside=T, col=rainbow(7), xlab="generation", ylab = " defense average", main="graph of speed")
barplot(cbind(generation.total$hp) ~ generation.total$generation, beside=T, col=rainbow(7), xlab="generation", ylab = " defense average", main="graph of hp")
barplot(cbind(generation.total$sp_attack) ~ generation.total$generation, beside=T, col=rainbow(7), xlab="generation", ylab = " defense average", main="graph of sp_attack")
barplot(cbind(generation.total$sp_defense) ~ generation.total$generation, beside=T, col=rainbow(7), xlab="generation", ylab = " defense average", main="graph of sp_defense")
barplot(cbind(generation.total$is_legendary) ~ generation.total$generation, beside=T, col=rainbow(7), xlab="generation", ylab = "average", main="graph of is_legendary")
barplot(cbind(generation.total$base_total) ~ generation.total$generation, beside=T, col=rainbow(7), xlab="generation", ylab = "average", main="graph of base_total")
barplot(cbind(generation.total$experience_growth) ~ generation.total$generation, beside=T, col=rainbow(7), xlab="generation", ylab = "average", main="graph of experience_growth")
barplot(cbind(generation.total$base_happiness) ~ generation.total$generation, beside=T, col=rainbow(7), xlab="generation", ylab = "average", main="graph of base_happiness")
barplot(cbind(generation.total$base_egg_steps) ~ generation.total$generation, beside=T, col=rainbow(7), xlab="generation", ylab = "average", main="graph of base_egg_steps")
barplot(cbind(generation.total$against_bug) ~ generation.total$generation, beside=T, col=rainbow(7), xlab="generation", ylab = "average", main="graph of against_bug")
barplot(cbind(generation.total$against_dark) ~ generation.total$generation, beside=T, col=rainbow(7), xlab="generation", ylab = "average", main="graph of against_dark")
barplot(cbind(generation.total$against_dragon) ~ generation.total$generation, beside=T, col=rainbow(7), xlab="generation", ylab = "average", main="graph of against_dragon")
barplot(cbind(generation.total$against_electric) ~ generation.total$generation, beside=T, col=rainbow(7), xlab="generation", ylab = "average", main="graph of against_electric")
barplot(cbind(generation.total$against_fairy) ~ generation.total$generation, beside=T, col=rainbow(7), xlab="generation", ylab = "average", main="graph of against_fairy")
barplot(cbind(generation.total$against_fight) ~ generation.total$generation, beside=T, col=rainbow(7), xlab="generation", ylab = "average", main="graph of against_fight")
barplot(cbind(generation.total$against_fire) ~ generation.total$generation, beside=T, col=rainbow(7), xlab="generation", ylab = "average", main="graph of against_fire")
barplot(cbind(generation.total$against_flying) ~ generation.total$generation, beside=T, col=rainbow(7), xlab="generation", ylab = "average", main="graph of against_flying")
barplot(cbind(generation.total$against_ghost) ~ generation.total$generation, beside=T, col=rainbow(7), xlab="generation", ylab = "average", main="graph of against_ghost")
barplot(cbind(generation.total$against_grass) ~ generation.total$generation, beside=T, col=rainbow(7), xlab="generation", ylab = "average", main="graph of against_grass")
barplot(cbind(generation.total$against_ground) ~ generation.total$generation, beside=T, col=rainbow(7), xlab="generation", ylab = "average", main="graph of against_ground")
barplot(cbind(generation.total$against_ice) ~ generation.total$generation, beside=T, col=rainbow(7), xlab="generation", ylab = "average", main="graph of against_ice")
barplot(cbind(generation.total$against_normal) ~ generation.total$generation, beside=T, col=rainbow(7), xlab="generation", ylab = "average", main="graph of against_normal")
barplot(cbind(generation.total$against_poison) ~ generation.total$generation, beside=T, col=rainbow(7), xlab="generation", ylab = "average", main="graph of against_poison")
barplot(cbind(generation.total$against_rock) ~ generation.total$generation, beside=T, col=rainbow(7), xlab="generation", ylab = "average", main="graph of against_rock")
barplot(cbind(generation.total$against_steel) ~ generation.total$generation, beside=T, col=rainbow(7), xlab="generation", ylab = "average", main="graph of against_steel")
barplot(cbind(generation.total$against_water) ~ generation.total$generation, beside=T, col=rainbow(7), xlab="generation", ylab = "average", main="graph of against_water")
pokemon[pokemon$name == 'Pikachu', ]
## abilities against_bug against_dark against_dragon
## 25 ['Static', 'Lightningrod'] 1 1 1
## against_electric against_fairy against_fight against_fire against_flying
## 25 0.5 1 1 1 0.5
## against_ghost against_grass against_ground against_ice against_normal
## 25 1 1 2 1 1
## against_poison against_psychic against_rock against_steel against_water
## 25 1 1 1 0.5 1
## attack base_egg_steps base_happiness base_total capture_rate classfication
## 25 55 2560 70 320 190 Mouse Pokemon
## defense experience_growth height_m hp name percentage_male pokedex_number
## 25 40 1000000 0.4 35 Pikachu 50 25
## sp_attack sp_defense speed type1 type2 weight_kg generation is_legendary
## 25 50 50 90 electric 6 1 0
Pikachu의 능력치에 대한 설명은 아래와 같다. against_ground: 상대 몬스터의 타입이 ground일 경우 피카츄가 받는 피해량이 다른 타입에 비해 더 높다 피카츄의 기본적인 상태수치는 hp=35 height= 0.4 attack=55 defense=40 sp.attack=50, sp.defense=50 speed=90 따라서 ground-type에서 피카츄의 기본적인 상태수치보다 높은 포켓몬들을 선택하도록 하였다.
against_Pikachu<-pokemon[pokemon$type1=='ground',c('name','against_electric','hp','height_m','attack','defense','sp_attack','sp_defense')]
hp_overPika <- subset(against_Pikachu, hp > 35)
attack_overPika <- subset(against_Pikachu, attack > 55)
defense_overPika <- subset(against_Pikachu, defense > 40)
spattack_overPika <- subset(against_Pikachu, sp_attack > 50)
spdefense_overPika <- subset(against_Pikachu, sp_defense > 50)
z<-merge(hp_overPika,attack_overPika)
y<-merge(z,defense_overPika)
x<-merge(y,spattack_overPika)
VS_pika<-merge(x,spdefense_overPika)
VS_pika
## name against_electric hp height_m attack defense sp_attack sp_defense
## 1 Claydol 0 60 1.5 70 105 70 120
## 2 Donphan 0 90 1.1 120 120 60 60
## 3 Flygon 0 80 2.0 100 80 80 80
## 4 Golurk 0 89 2.8 124 80 55 80
## 5 Groudon 0 100 3.5 180 160 150 90
## 6 Hippowdon 0 108 2.0 112 118 68 72
## 7 Krookodile 0 95 1.5 117 80 65 70
## 8 Landorus 0 89 1.5 145 90 105 80
## 9 Mudsdale 0 100 2.5 125 100 55 85
## 10 Rhyperior 0 115 2.4 140 130 55 55
## 11 Stunfisk 0 109 0.7 66 84 81 99
sampleVS<-VS_pika[sample(1:11,10),]
sampleVS
## name against_electric hp height_m attack defense sp_attack sp_defense
## 8 Landorus 0 89 1.5 145 90 105 80
## 5 Groudon 0 100 3.5 180 160 150 90
## 11 Stunfisk 0 109 0.7 66 84 81 99
## 10 Rhyperior 0 115 2.4 140 130 55 55
## 7 Krookodile 0 95 1.5 117 80 65 70
## 6 Hippowdon 0 108 2.0 112 118 68 72
## 4 Golurk 0 89 2.8 124 80 55 80
## 9 Mudsdale 0 100 2.5 125 100 55 85
## 2 Donphan 0 90 1.1 120 120 60 60
## 1 Claydol 0 60 1.5 70 105 70 120
head(pokemon[pokemon$is_legendary == 1, ], 5)
## abilities against_bug against_dark against_dragon
## 144 ['Pressure', 'Snow Cloak'] 0.50 1 1
## 145 ['Pressure', 'Static'] 0.50 1 1
## 146 ['Pressure', 'Flame Body'] 0.25 1 1
## 150 ['Pressure', 'Unnerve'] 2.00 2 1
## 151 ['Synchronize'] 2.00 2 1
## against_electric against_fairy against_fight against_fire against_flying
## 144 2 1.0 1.0 2.0 1.0
## 145 1 1.0 0.5 1.0 0.5
## 146 2 0.5 0.5 0.5 1.0
## 150 1 1.0 0.5 1.0 1.0
## 151 1 1.0 0.5 1.0 1.0
## against_ghost against_grass against_ground against_ice against_normal
## 144 1 0.50 0 1 1
## 145 1 0.50 0 2 1
## 146 1 0.25 0 1 1
## 150 2 1.00 1 1 1
## 151 2 1.00 1 1 1
## against_poison against_psychic against_rock against_steel against_water
## 144 1 1.0 4 2.0 1
## 145 1 1.0 2 0.5 1
## 146 1 1.0 4 0.5 2
## 150 1 0.5 1 1.0 1
## 151 1 0.5 1 1.0 1
## attack base_egg_steps base_happiness base_total capture_rate
## 144 85 20480 35 580 3
## 145 90 20480 35 580 3
## 146 100 20480 35 580 3
## 150 150 30720 0 780 3
## 151 100 30720 100 600 45
## classfication defense experience_growth height_m hp name
## 144 Freeze Pokemon 100 1250000 1.7 90 Articuno
## 145 Electric Pokemon 85 1250000 1.6 90 Zapdos
## 146 Flame Pokemon 90 1250000 2.0 90 Moltres
## 150 Genetic Pokemon 70 1250000 2.0 106 Mewtwo
## 151 New Species Pokemon 100 1059860 0.4 100 Mew
## percentage_male pokedex_number sp_attack sp_defense speed type1 type2
## 144 NA 144 95 125 85 ice flying
## 145 NA 145 125 90 100 electric flying
## 146 NA 146 125 85 90 fire flying
## 150 NA 150 194 120 140 psychic
## 151 NA 151 100 100 100 psychic
## weight_kg generation is_legendary
## 144 55.4 1 1
## 145 52.6 1 1
## 146 60.0 1 1
## 150 122.0 1 1
## 151 4.0 1 1
legend_height<-aggregate(height_m~is_legendary,data=pokemon,FUN=mean)
legend_weight<-aggregate(weight_kg~is_legendary,data=pokemon,FUN=mean)
legend_attack<-aggregate(attack~is_legendary,data=pokemon,FUN=mean)
legend_defense<-aggregate(defense~is_legendary,data=pokemon,FUN=mean)
legend_hp<-aggregate(hp~is_legendary,data=pokemon,FUN=mean)
l1<-merge(legend_attack,legend_defense)
l2<-merge(l1,legend_height)
l3<-merge(l2,legend_weight)
legendary_compare<-merge(l3,legend_hp)
table(pokemon$is_legendary)
##
## 0 1
## 731 70
table(pokemon$is_legendary,pokemon$type1)
##
## bug dark dragon electric fairy fighting fire flying ghost grass ground ice
## 0 69 26 20 34 17 28 47 2 26 74 30 21
## 1 3 3 7 5 1 0 5 1 1 4 2 2
##
## normal poison psychic rock steel water
## 0 102 32 36 41 18 108
## 1 3 0 17 4 6 6
legendary_compare
## is_legendary attack defense height_m weight_kg hp
## 1 0 74.84131 70.48153 1.055618 48.00716 66.42408
## 2 1 109.35714 99.40000 2.281159 199.35072 95.42857
type1.total <- aggregate(cbind(attack, defense, speed, hp, sp_attack, sp_defense) ~ type1, data=pokemon, FUN= mean)
barplot(cbind(type1.total$attack, type1.total$defense, type1.total$speed, type1.total$hp, type1.total$sp_attack, type1.total$sp_defense) ~ type1.total$type1,
beside=T, col=rainbow(6), xlab="type", ylab = "average", main="graph of type1",horiz=F)
#axis(side=2, at=seq(0,120,20))
legend("bottomright", legend=c("attack", "defense", "speed", "HP", "sp_attack", "sp_defense"), fill=rainbow(6))